package model;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;

public class Catalog implements java.io.Serializable{
	private ArrayList<Hall> ListOfHalls = new ArrayList<Hall>();
	private static Catalog UniqueInstance = null;
	
	
	//singleton
	public static Catalog getInstance(){
		if(UniqueInstance == null){
			UniqueInstance = new Catalog();
		}
		return UniqueInstance;
	}

	private Catalog(){
		ListOfHalls.add(Hall1.getInstance());
		ListOfHalls.add(Hall2.getInstance());
		ListOfHalls.add(Hall3.getInstance());
	}
	
	public void viewAllEvents(){
		for(int i = 0; i<ListOfHalls.size(); i++){
			//System.out.println(ListOfHalls.get(i).getName() + ":");
			ListOfHalls.get(i).viewAllHallEvents();	
		}	
		System.out.println();	
	}
	
	public Event finfEventbyID(int ID){
		for(int i = 0; i<ListOfHalls.size(); i++){
			for(int j = 0; j<ListOfHalls.get(i).getListOfEvent().size(); j++){
				if(ListOfHalls.get(i).getListOfEvent().get(j).getID() == ID){
					System.out.println("Event found: "+ListOfHalls.get(i).getListOfEvent().get(j));
					return ListOfHalls.get(i).getListOfEvent().get(j);
				}
			}
		}
		System.out.println("No event with ID=" + ID + " was found");
		return null;
	}
	//public void setUniqueInstance(Catalog c){
	//	UniqueInstance = c;
	//}
	

}
